<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>管理登陆</title>
    
    <meta charset="utf-8"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="gold/css/style.css">
	<link rel="stylesheet" href="gold/css/bootstrap.css">
	
	
	
	<script type="text/javascript" src="gold/js/jquery.js"></script>
	<!-- MAIN EFFECT -->
	<script type="text/javascript" src="gold/js/bootstrap.js"></script>
	
	<%--
	<link rel="shortcut icon" href="assets/ico/minus.png">
	--%>
	<script src="gold/js/jquery-1.7.2.min.js"></script>
	<style type="text/css">
		#zhong {
			margin-top: 200px;
		}
		
		#yzmsj {
			display: none;
		}
		#1 {
			color: green;
		}
		.row-block{
			margin-top: 50px;
			font-size: 18px;
			color: red;
		}
		#btn{
			margin-left:-30px;
			width:100px;
			height:37px;
		}
		.col-sm-9{
			margin-left:40px;
		}
		#checkCode{
			width:100px;
		}
	</style>

  </head>
  
  <body>
    <div id="preloader"></div>
	<div class="container">
		<div id="zhong">
			<div class="" id="login-wrapper">
				<div class="row">
					<div class="col-md-4 col-md-offset-4">
						<div id="logo-login">
							<h1>游币后台登录页面</h1>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-4 col-md-offset-4">
						<div class="account-box">
							<form action="adminLogin.do" method="post">
								<div class="row">
									<div class="col-sm-9">
										<label for="inputUsername">用户名</label>
										<div class="row">
											<div class="col-xs-8 col-sm-12 zg1">
												<input type="text"
													required="required" class="form-control" name="adminName" id="adminName">
											</div>
											<div class="col-xs-3 col-sm-5">
												<span id="1"></span>
											</div>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-sm-9">
										<label for="inputUsername">密码</label>
										<div class="row">
											<div class="col-xs-8 col-sm-12">
												<input type="password"
													required="required" 
													class="form-control" name="adminPwd">
											</div>
											<div class="col-xs-3 col-sm-5">
												<span id="2"></span>
											</div>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-sm-9">
										<label for="inputverificationcode">验证码 </label>
										<div class="row">
											<div class="col-xs-8 col-sm-8">
												<input type="text" required="required"  class="form-control" name="checkCode" id="checkCode">
											</div>
											<div class="col-xs-2 col-sm-2">
												<input class="btn btn-warning " type="button" id="btn"
													value="获取验证码" onclick="getCode(this)"/>
											</div>
										</div>
									</div>
								</div>
								
								<div class="row" id="3">
									&nbsp;
								</div>
								<button id="start" class="btn btn btn-primary " disabled="disabled" type="submit">登 录
								</button>
							</form>
						</div>
						<div class="row-block">
								<div class="row" id="msg">${msg}</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
  </body>
  <script type="text/javascript">
  	var v1;
  	var v2;
  	
  	function getCode(obj){
  		v1 = 30;
  		$(obj).attr("disabled","disabled");
  		$("#start").removeAttr("disabled");
  		checkCode();
  		getAjaxCode();
  	}
  	function checkCode(){
  		v1 = v1 - 1;
  		if(v1 < 0){
  			$("#btn").val("获取验证码");
  			$("#start").attr("disabled","disabled");
  			$("#btn").removeAttr("disabled");
  		}else{
	  		$("#btn").val(v1);
	  		var v2 = setTimeout(checkCode,1000);
  		}
  	}
  	function getAjaxCode(){
  		$.ajax({
  			url:"getAjaxCode.do",
  			type:"post",
  			data:{"adminName":$("#adminName").val()},
  			dataType:"json",
  			success:function(result){
  				if(result.check==false){
  					$("#start").attr("disabled","disabled");
  				}
  				$("#3").text(result.msg);
  				
  			}
  		});
  	}
  	
  	function checkAjaxCode(flag){
  		$.ajax({
  				url:"checkAjaxCode.do",
  				type:"post",
  				data:{"code":$("#checkCode").val()},
  				dataType:"json",
  				async: false,
  				success:function(result){
					flag = result.check;
  					if(result.check==true){
  						$("#msg").text("");
  					}else{
  						alert(flag);
  						$("#msg").text(result.msg);
  					}
  				}
  			});
  	}
  	
  	$(function(){
  		var flag = false;
  		$("form").submit(function(){
  			$.ajax({
  				url:"checkAjaxCode.do",
  				type:"post",
  				data:{"code":$("#checkCode").val()},
  				dataType:"json",
  				async: false,
  				success:function(result){
					flag = result.check;
  					if(result.check==true){
  						$("#msg").text("");
  					}else{
  						$("#msg").text(result.msg);
  					}
  				}
  			});
  			return flag;
  		});
  	});
  
  </script>
</html>
